package assist.datastore.dao;


import assist.datastore.Datastore;
import assist.datastore.JDODatastore;
import assist.datastore.dao.GameDAO;
import assist.datastore.dao.PlayerDAO;
import assist.domain.model.BlockedShot;
import assist.domain.model.Game;
import assist.domain.model.Goal;
import assist.domain.model.MissedShot;
import assist.domain.model.Player;
import assist.domain.model.ShotOnGoal;
import assist.domain.model.Team;

/**
 * Creates the JDO DAO objects, which need a JDO implementation of the 
 * Datastore.  This class is also the JDO implementation of the Datastore.
 * The Datastore implements the actual CRUD operations, and this class should 
 * be the only one that needs to change when we switch Datastore back ends.
 * 
 * NOTE: The Objectify Factory will use the DAOBase for implementing these
 * methods.
 * 
 * NOTE: We MAY still need custom DAOs for each:
 */
class JDODAOFactory extends DAOFactory
{    
    private Datastore<Game> gameDatastore = new JDODatastore<Game>();
    private Datastore<Player> playerDatastore = new JDODatastore<Player>();
    private Datastore<ShotOnGoal> shotOnGoalDatastore = 
        new JDODatastore<ShotOnGoal>();
    private Datastore<BlockedShot> blockedShotDatastore = 
        new JDODatastore<BlockedShot>();
    private Datastore<MissedShot> missedShotDatastore = 
        new JDODatastore<MissedShot>();
    private Datastore<Goal> goalDatastore = new JDODatastore<Goal>();
    private Datastore<Team> teamDatastore = new JDODatastore<Team>();
    
    JDODAOFactory()
    {
        
    }
    
    @Override
    public GameDAO getGameDAO()
    {       
        return new GameDAO(this.gameDatastore);
    }

    @Override
    public PlayerDAO getPlayerDAO()
    {
        return new PlayerDAO(this.playerDatastore);
    }

    @Override
    public ShotOnGoalDAO getShotOnGoalDAO()
    {
        return new ShotOnGoalDAO(this.shotOnGoalDatastore);
    }

    @Override
    public BlockedShotDAO getBlockedShotDAO()
    {
        return new BlockedShotDAO(this.blockedShotDatastore);
    }

    @Override
    public MissedShotDAO getMissedShotDAO()
    {
        return new MissedShotDAO(this.missedShotDatastore);
    }

    @Override
    public GoalDAO getGoalDAO()
    {
        return new GoalDAO(this.goalDatastore);
    }

    @Override
    public ShotDAO getShotDAO()
    {
        return new ShotDAO();
    }

    @Override
    public void reset()
    {
        JDODatastore.reset();
    }

    @Override
    public TeamDAO getTeamDAO()
    {
        return new TeamDAO(this.teamDatastore);
    }
}
